﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace EntityModel.Migrations
{
    /// <inheritdoc />
    public partial class Init : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterDatabase()
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "A1",
                columns: table => new
                {
                    _01 = table.Column<Guid>(name: "01", type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    A001 = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    A002 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    A003 = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    A004 = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    A005 = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    A006 = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    A007 = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    _02 = table.Column<DateTime>(name: "02", type: "datetime(6)", nullable: false),
                    _03 = table.Column<DateTime>(name: "03", type: "datetime(6)", nullable: true),
                    _04 = table.Column<DateTime>(name: "04", type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_A1", x => x._01);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "B01",
                columns: table => new
                {
                    _01 = table.Column<Guid>(name: "01", type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    B001 = table.Column<int>(type: "int", nullable: false),
                    B002 = table.Column<int>(type: "int", nullable: false),
                    B003 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    B004 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    B005 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    _02 = table.Column<DateTime>(name: "02", type: "datetime(6)", nullable: false),
                    _03 = table.Column<DateTime>(name: "03", type: "datetime(6)", nullable: true),
                    _04 = table.Column<DateTime>(name: "04", type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_B01", x => x._01);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "B02",
                columns: table => new
                {
                    _01 = table.Column<Guid>(name: "01", type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    B100 = table.Column<int>(type: "int", nullable: false),
                    B101 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    B102 = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    B103 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    B104 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    _02 = table.Column<DateTime>(name: "02", type: "datetime(6)", nullable: false),
                    _03 = table.Column<DateTime>(name: "03", type: "datetime(6)", nullable: true),
                    _04 = table.Column<DateTime>(name: "04", type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_B02", x => x._01);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "B03",
                columns: table => new
                {
                    _01 = table.Column<Guid>(name: "01", type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    B200 = table.Column<int>(type: "int", nullable: false),
                    B201 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    B202 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    B203 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    B204 = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    _02 = table.Column<DateTime>(name: "02", type: "datetime(6)", nullable: false),
                    _03 = table.Column<DateTime>(name: "03", type: "datetime(6)", nullable: true),
                    _04 = table.Column<DateTime>(name: "04", type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_B03", x => x._01);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "C01",
                columns: table => new
                {
                    _01 = table.Column<Guid>(name: "01", type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    C001 = table.Column<double>(type: "double", nullable: false),
                    C002 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    C003 = table.Column<double>(type: "double", nullable: false),
                    C004 = table.Column<double>(type: "double", nullable: false),
                    _02 = table.Column<DateTime>(name: "02", type: "datetime(6)", nullable: false),
                    _03 = table.Column<DateTime>(name: "03", type: "datetime(6)", nullable: true),
                    _04 = table.Column<DateTime>(name: "04", type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_C01", x => x._01);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "A2",
                columns: table => new
                {
                    _01 = table.Column<Guid>(name: "01", type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    A001 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    A002 = table.Column<bool>(type: "tinyint(30)", maxLength: 30, nullable: false),
                    A003 = table.Column<int>(type: "int", nullable: false),
                    A004 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    A005 = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    A006 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    A007 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    EM_EnrollId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    _02 = table.Column<DateTime>(name: "02", type: "datetime(6)", nullable: false),
                    _03 = table.Column<DateTime>(name: "03", type: "datetime(6)", nullable: true),
                    _04 = table.Column<DateTime>(name: "04", type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_A2", x => x._01);
                    table.ForeignKey(
                        name: "FK_A2_A1_EM_EnrollId",
                        column: x => x.EM_EnrollId,
                        principalTable: "A1",
                        principalColumn: "01");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "A3",
                columns: table => new
                {
                    _01 = table.Column<Guid>(name: "01", type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    A001 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    A002 = table.Column<int>(type: "int", nullable: false),
                    A003 = table.Column<bool>(type: "tinyint(30)", maxLength: 30, nullable: false),
                    A004 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    A005 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    A006 = table.Column<double>(type: "double", nullable: false),
                    A007 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    EM_EnrollId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    _02 = table.Column<DateTime>(name: "02", type: "datetime(6)", nullable: false),
                    _03 = table.Column<DateTime>(name: "03", type: "datetime(6)", nullable: true),
                    _04 = table.Column<DateTime>(name: "04", type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_A3", x => x._01);
                    table.ForeignKey(
                        name: "FK_A3_A1_EM_EnrollId",
                        column: x => x.EM_EnrollId,
                        principalTable: "A1",
                        principalColumn: "01");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "C02",
                columns: table => new
                {
                    _01 = table.Column<Guid>(name: "01", type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    C001 = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    C002 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    C003 = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    C004 = table.Column<float>(type: "float", nullable: false),
                    C005 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    C006 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    C007 = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    EM_StudentsId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    _02 = table.Column<DateTime>(name: "02", type: "datetime(6)", nullable: false),
                    _03 = table.Column<DateTime>(name: "03", type: "datetime(6)", nullable: true),
                    _04 = table.Column<DateTime>(name: "04", type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_C02", x => x._01);
                    table.ForeignKey(
                        name: "FK_C02_A2_EM_StudentsId",
                        column: x => x.EM_StudentsId,
                        principalTable: "A2",
                        principalColumn: "01");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "C03",
                columns: table => new
                {
                    _01 = table.Column<Guid>(name: "01", type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    C001 = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    C002 = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    C003 = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    C004 = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    C005 = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    EM_StudentsId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    _02 = table.Column<DateTime>(name: "02", type: "datetime(6)", nullable: false),
                    _03 = table.Column<DateTime>(name: "03", type: "datetime(6)", nullable: true),
                    _04 = table.Column<DateTime>(name: "04", type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_C03", x => x._01);
                    table.ForeignKey(
                        name: "FK_C03_A2_EM_StudentsId",
                        column: x => x.EM_StudentsId,
                        principalTable: "A2",
                        principalColumn: "01");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "D1",
                columns: table => new
                {
                    _01 = table.Column<Guid>(name: "01", type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    D001 = table.Column<int>(type: "int", nullable: false),
                    D002 = table.Column<int>(type: "int", nullable: false),
                    D003 = table.Column<int>(type: "int", nullable: false),
                    D004 = table.Column<int>(type: "int", nullable: false),
                    D005 = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    D006 = table.Column<int>(type: "int", nullable: false),
                    D007 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    EM_StudentsId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    _02 = table.Column<DateTime>(name: "02", type: "datetime(6)", nullable: false),
                    _03 = table.Column<DateTime>(name: "03", type: "datetime(6)", nullable: true),
                    _04 = table.Column<DateTime>(name: "04", type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_D1", x => x._01);
                    table.ForeignKey(
                        name: "FK_D1_A2_EM_StudentsId",
                        column: x => x.EM_StudentsId,
                        principalTable: "A2",
                        principalColumn: "01");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "D2",
                columns: table => new
                {
                    _01 = table.Column<Guid>(name: "01", type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    D001 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    D002 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    D003 = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    D004 = table.Column<int>(type: "int", nullable: false),
                    D005 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    D006 = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    D007 = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    D008 = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    D009 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    EM_StudentsId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    _02 = table.Column<DateTime>(name: "02", type: "datetime(6)", nullable: false),
                    _03 = table.Column<DateTime>(name: "03", type: "datetime(6)", nullable: true),
                    _04 = table.Column<DateTime>(name: "04", type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_D2", x => x._01);
                    table.ForeignKey(
                        name: "FK_D2_A2_EM_StudentsId",
                        column: x => x.EM_StudentsId,
                        principalTable: "A2",
                        principalColumn: "01");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "D3",
                columns: table => new
                {
                    _01 = table.Column<Guid>(name: "01", type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    D001 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    D002 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    D003 = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    D004 = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    D005 = table.Column<int>(type: "int", maxLength: 50, nullable: false),
                    D006 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    EM_StudentsId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    _02 = table.Column<DateTime>(name: "02", type: "datetime(6)", nullable: false),
                    _03 = table.Column<DateTime>(name: "03", type: "datetime(6)", nullable: true),
                    _04 = table.Column<DateTime>(name: "04", type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_D3", x => x._01);
                    table.ForeignKey(
                        name: "FK_D3_A2_EM_StudentsId",
                        column: x => x.EM_StudentsId,
                        principalTable: "A2",
                        principalColumn: "01");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "EM_ScoreEM_Students",
                columns: table => new
                {
                    EM_ScoreId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EM_ScoreEM_Students", x => new { x.EM_ScoreId, x.UserId });
                    table.ForeignKey(
                        name: "FK_EM_ScoreEM_Students_A2_UserId",
                        column: x => x.UserId,
                        principalTable: "A2",
                        principalColumn: "01",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_EM_ScoreEM_Students_C01_EM_ScoreId",
                        column: x => x.EM_ScoreId,
                        principalTable: "C01",
                        principalColumn: "01",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_A2_EM_EnrollId",
                table: "A2",
                column: "EM_EnrollId");

            migrationBuilder.CreateIndex(
                name: "IX_A3_EM_EnrollId",
                table: "A3",
                column: "EM_EnrollId");

            migrationBuilder.CreateIndex(
                name: "IX_C02_EM_StudentsId",
                table: "C02",
                column: "EM_StudentsId");

            migrationBuilder.CreateIndex(
                name: "IX_C03_EM_StudentsId",
                table: "C03",
                column: "EM_StudentsId");

            migrationBuilder.CreateIndex(
                name: "IX_D1_EM_StudentsId",
                table: "D1",
                column: "EM_StudentsId");

            migrationBuilder.CreateIndex(
                name: "IX_D2_EM_StudentsId",
                table: "D2",
                column: "EM_StudentsId");

            migrationBuilder.CreateIndex(
                name: "IX_D3_EM_StudentsId",
                table: "D3",
                column: "EM_StudentsId");

            migrationBuilder.CreateIndex(
                name: "IX_EM_ScoreEM_Students_UserId",
                table: "EM_ScoreEM_Students",
                column: "UserId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "A3");

            migrationBuilder.DropTable(
                name: "B01");

            migrationBuilder.DropTable(
                name: "B02");

            migrationBuilder.DropTable(
                name: "B03");

            migrationBuilder.DropTable(
                name: "C02");

            migrationBuilder.DropTable(
                name: "C03");

            migrationBuilder.DropTable(
                name: "D1");

            migrationBuilder.DropTable(
                name: "D2");

            migrationBuilder.DropTable(
                name: "D3");

            migrationBuilder.DropTable(
                name: "EM_ScoreEM_Students");

            migrationBuilder.DropTable(
                name: "A2");

            migrationBuilder.DropTable(
                name: "C01");

            migrationBuilder.DropTable(
                name: "A1");
        }
    }
}
